#pragma once
#include <string>
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;
namespace data
{
	template<typename T>
	T* load_from_file(const char* path)
	{
		
		auto file = fopen ( path , "rb" );		
		fseek (file , 0 , SEEK_END);
		auto bytesize  = ftell (file);
		rewind (file);
		T* data = (T*)malloc(bytesize);
		assert(fread (data, 1, bytesize, file) == bytesize);
		fclose (file);
		return data;
	}
	template<typename T>
	void save_to_file(T* source, const char* path)
	{
		auto file = fopen ( path , "wb" );
		fwrite (source, 1, source->byte_size, file);
		fclose (file);
	}
}